<template>
    <div class="myTag">
        <el-tag :type="myType">{{typeTxt}}</el-tag>
    </div>
</template>
<script>
export default {
    name:'myTag',
    props:{
        levelData:{
            type:String
        }
    },
    data() {
        return {
            level:this.$props.levelData,
            myType:'',
            typeTxt:''
        }
    },
    watch:{
        'level':{
            handler:function (newVal,oldVal) {
                if (this.$route.path==='/rights') {
                    switch (newVal) {
                    case '1': 
                        //console.log('1');
                        this.myType='success'
                        this.typeTxt='等级二'
                        break; 
                    case '2': 
                        //console.log('2');
                        this.myType='warning'
                        this.typeTxt='等级三'
                        break 
                    default:
                        //console.log('default');
                        this.myType=''
                        this.typeTxt='等级一'
                        break 
                }
                }
                if (this.$route.path==='/categories') {
                    switch (newVal) {
                    case '1': 
                        //console.log('1');
                        this.myType='success'
                        this.typeTxt='二级'
                        break; 
                    case '2': 
                        //console.log('2');
                        this.myType='warning'
                        this.typeTxt='三级'
                        break 
                    default:
                        //console.log('default');
                        this.myType=''
                        this.typeTxt='一级'
                        break 
                }
                }
                
            },
            immediate:true
        }
    }
}
</script>
<style lang="scss">
    .myTag{

    }
</style>